import easygui as g
import os
path=g.diropenbox()
count=0
dirt1={}
list2=['.c', '.cpp', '.py', '.cc', '.java', '.pas', '.asm']
list1=list(os.walk(path))
for wd in range(len(list1)):
    for document in list1[wd][2]:
        flag=os.path.splitext(document)[1]
        if flag in list2:
            dirt1[flag]=0
            print('正在分析文件:%s'%document)
            dirt1[flag]+=1
            with open(document,'r',encoding='utf-8') as f1:
                f1.seek(0,0)
                for i in f1:
                    if i != '': 
                        count+=1
内容 = ''
进度 = str(count/1000)+'%'
剩余 = 100000-count
for i in dirt1.keys():
    内容 += '【%s】文件共%d个，代码%d行\n' %(i,dirt1[i],count)
msg = '您目前共累积编写了%d行代码，完成进度%s\n离10万行代码\
还差%d行，请继续努力'% (count,进度,剩余)
g.textbox(msg,'统计结果',内容)
